<template>
  <div>
    <div class="header-box">
      <p>宏烨找房后台管理系统</p>
      <div class="iphonelist">
        <!-- 如果写用户信息头像的排版自定义写法 -->
        <div class="rightlist">
          <li>
            <img :src="list.img" alt />
          </li>

          <div class="nav">
            <p class="namelist">高级经纪人:{{list.name}}</p>
          </div>

          <button @click="tuichu" class="btn">退出登录</button>
        </div>
      </div>
      <!-- 在一个盒子里给父系元素加display:flew 能让里面的东西在一行 -->
    </div>
  </div>
</template>
<script>
import { lo } from "../api/user";
export default {
  data() {
    return {
      list: [],
      token: ""
    };
  },
  created() {
    //拿到token值
    this.token = localStorage.getItem("token");

    this.getinfo();
  },
  methods: {
    //拿到调用的数据
    getinfo() {
      lo({ token: this.token }).then(res => {
        this.list = res.data;
      });
    },
    tuichu() {
      //清空token值
      localStorage.removeItem("token");
      //跳转登录页面
      this.$router.push("/login");
    }
  }
};
</script>
<style lang="scss">
.header-box {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 30px;
  height: 64px;
  box-shadow: 0px 1px 4px 0px rgba(0, 21, 41, 0.12);
  background: rgb(14, 113, 243);
  align-items: center;
  color: #fff;
}
.rightlist {
  display: flex;
}
.namelist {
  margin-right: 20px;
  margin-top: 46px;
}
.iphonelist li {
  width: 60px;
  height: 60px;
}
.iphonelist li img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.btn {
  width: 50px;
  height: 50px;
  margin-top: 10px;
  background: blueviolet;
}
</style>